/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "activity")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Activity.findAll", query = "SELECT a FROM Activity a"),
    @NamedQuery(name = "Activity.findByActivityId", query = "SELECT a FROM Activity a WHERE a.activityId = :activityId"),
    @NamedQuery(name = "Activity.findByDisplayName", query = "SELECT a FROM Activity a WHERE a.displayName = :displayName"),
    @NamedQuery(name = "Activity.findByAssessment", query = "SELECT a FROM Activity a WHERE a.assessment = :assessment"),
    @NamedQuery(name = "Activity.findByTimeEstimate", query = "SELECT a FROM Activity a WHERE a.timeEstimate = :timeEstimate")
})
public class Activity implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "activity_id")
    private Long activityId;
    @Size(max = 256)
    @Column(name = "display_name")
    private String displayName;
    @Lob
    @Size(max = 65535)
    @Column(name = "description")
    private String description;
    @Size(max = 5)
    @Column(name = "assessment")
    private String assessment;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "time_estimate")
    private Float timeEstimate;
    @JoinTable(name = "activity_ilo", joinColumns =
    {
        @JoinColumn(name = "activity_id", referencedColumnName = "activity_id")
    }, inverseJoinColumns =
    {
        @JoinColumn(name = "ilo_id", referencedColumnName = "ilo_id")
    })
    @ManyToMany
    private Collection<Ilo> iloCollection;
    @JoinTable(name = "activity_sweetie", joinColumns =
    {
        @JoinColumn(name = "activity_id", referencedColumnName = "activity_id")
    }, inverseJoinColumns =
    {
        @JoinColumn(name = "sweetie_id", referencedColumnName = "sweetie_id")
    })
    @ManyToMany
    private Collection<Sweetie> sweetieCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activity")
    private Collection<ActivityAssessment> activityAssessmentCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activityId")
    private Collection<ActivityUrl> activityUrlCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activity")
    private Collection<KnodeActivity> knodeActivityCollection;

    public Activity()
    {
    }

    public Activity(Long activityId)
    {
        this.activityId = activityId;
    }

    public Long getActivityId()
    {
        return activityId;
    }

    public void setActivityId(Long activityId)
    {
        this.activityId = activityId;
    }

    public String getDisplayName()
    {
        return displayName;
    }

    public void setDisplayName(String displayName)
    {
        this.displayName = displayName;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getAssessment()
    {
        return assessment;
    }

    public void setAssessment(String assessment)
    {
        this.assessment = assessment;
    }

    public Float getTimeEstimate()
    {
        return timeEstimate;
    }

    public void setTimeEstimate(Float timeEstimate)
    {
        this.timeEstimate = timeEstimate;
    }

    @XmlTransient
    public Collection<Ilo> getIloCollection()
    {
        return iloCollection;
    }

    public void setIloCollection(Collection<Ilo> iloCollection)
    {
        this.iloCollection = iloCollection;
    }

    @XmlTransient
    public Collection<Sweetie> getSweetieCollection()
    {
        return sweetieCollection;
    }

    public void setSweetieCollection(Collection<Sweetie> sweetieCollection)
    {
        this.sweetieCollection = sweetieCollection;
    }

    @XmlTransient
    public Collection<ActivityAssessment> getActivityAssessmentCollection()
    {
        return activityAssessmentCollection;
    }

    public void setActivityAssessmentCollection(Collection<ActivityAssessment> activityAssessmentCollection)
    {
        this.activityAssessmentCollection = activityAssessmentCollection;
    }

    @XmlTransient
    public Collection<ActivityUrl> getActivityUrlCollection()
    {
        return activityUrlCollection;
    }

    public void setActivityUrlCollection(Collection<ActivityUrl> activityUrlCollection)
    {
        this.activityUrlCollection = activityUrlCollection;
    }

    @XmlTransient
    public Collection<KnodeActivity> getKnodeActivityCollection()
    {
        return knodeActivityCollection;
    }

    public void setKnodeActivityCollection(Collection<KnodeActivity> knodeActivityCollection)
    {
        this.knodeActivityCollection = knodeActivityCollection;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (activityId != null ? activityId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Activity))
        {
            return false;
        }
        Activity other = (Activity) object;
        if ((this.activityId == null && other.activityId != null) || (this.activityId != null && !this.activityId.equals(other.activityId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.Activity[ activityId=" + activityId + " ]";
    }

}
